package play.modules.fbauth;


import play.mvc.Http.Response;
import play.mvc.results.Ok;
import play.mvc.results.Redirect;

/**
 * Created by IntelliJ IDEA.
 * User: Jacky
 * Date: 20/01/2011
 * Time: 4:53 PM
 * To change this template use File | Settings | File Templates.
 */
public class FbAuthException extends Exception
{

    private String iframeCanvasRedirectHtml;

    private String url;

    private Response response;


    public FbAuthException( String message, String iframeCanvasRedirectHtml, String url, Response response )
    {
        super( message );
        this.iframeCanvasRedirectHtml = iframeCanvasRedirectHtml;
        this.url = url;
        this.response = response;
    }

    public String getIframeCanvasRedirectHtml()
    {
        return iframeCanvasRedirectHtml;
    }


    public String getUrl()
    {
        return url;
    }

    public void redirect()
    {
        response.reset();
        throw new Redirect( url );
    }

    public void redirectHtml(){
        response.reset();
        response.contentType = "text/html;charset=UTF-8";
        response.print( iframeCanvasRedirectHtml );
        throw new Ok();
    }
}
